#include<bits/stdc++.h>
using namespace std;
int a[100010],d[100010],s[100010],n,ans = 1e9;
void dfs(int h){
    if(h < ans) ans = h;
    for(int i = 1;i <= n;i++){
        if(d[i] || s[i]) continue;
        for(int j = 1;j <= n;j++){
            if(a[i] > a[j] && !s[j]){
                d[i] = 1,s[j] = 1;
                dfs(h - 1);
                d[i] = 0,s[j] = 0;
            }
        }
    }
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        d[i] = 0,s[i] = 0;
    }
    dfs(n);
    cout << ans << endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
